package javachongkao.面向对象上.定义类与创建对象;
//7-7 定义类与创建对象
//定义一个类Person,定义name和age属性，定义有参的构造方法对name和age进行初始化。在测试类中创建该类的2个对象，姓名、年龄分别为lili、19和lucy、20，在屏幕打印出2个对象的姓名和年龄。
//
//输入格式:
//本题目无输入
//
//输出格式:
//在一行中输出一个人的姓名和年龄
public class Main {
    public static void main(String[] args) {
        Person person1 = new Person("lili", 19);
        Person person2 = new Person("lucy", 20);
        System.out.println("this person is " + person1.getName() + ",her age is " + person1.getAge());
        System.out.println("this person is " + person2.getName() + ",her age is " + person2.getAge());
    }
}
class Person {
    private String name;
    private int age;
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public int getAge() {
        return age;
    }
}

